//
//  FZHomeCollectionCell.swift
//  MyWeiBo
//
//  Created by fangzhengwei on 2017/3/31.
//  Copyright © 2017年 fangzhengwei. All rights reserved.
//

import UIKit
//点击图片方法,再次点击缩小不会做
class FZHomeCollectionCell: UICollectionViewCell {
    
    var imgView : UIImageView = UIImageView()
    fileprivate lazy var gifImage : UIImageView = UIImageView(image: UIImage(named: "timeline_image_gif"))
    var imgUrlStr : FZPictureInfo? {
        
        didSet {
            if let imgStr = imgUrlStr?.thumbnail_pic {
                
                imgView.sd_setImage(with: URL(string : imgStr), placeholderImage: UIImage(named: "timeline_image_placeholder"))
                if imgStr.hasSuffix(".gif") {
                    gifImage.isHidden = false
                }else{
                    gifImage.isHidden = true
                }
            }
        }
    }
    
    override init(frame: CGRect) {
        super.init(frame: frame)
         setupUI()
    }
    
    func setupUI() {
//        imgView.isUserInteractionEnabled = false
        contentView.addSubview(gifImage)
        contentView.addSubview(imgView)
        imgView.snp.makeConstraints { (make) in
            
            make.edges.equalTo(self)
        }
        
        gifImage.snp.makeConstraints { (make) in
            make.right.equalTo(imgView)
            make.bottom.equalTo(imgView)
        }
        
        imgView.contentMode = .scaleAspectFill
        imgView.clipsToBounds = true
        imgView.isUserInteractionEnabled = true
//        let gesture = UITapGestureRecognizer(target: self, action: #selector(enlargeImg))
//        
//        imgView.addGestureRecognizer(gesture)
    }
    
    func enlargeImg() {
        
//        imgView.bounds = CGRect(x: 0, y: 0, width: screenWidth, height: screenHeight)
        
    }
    
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
}







